//
//  ZSLiveCollectionViewCell.m
//  ZSMiao
//
//  Created by zsj1992 on 16/12/2.
//  Copyright © 2016年 bjhj. All rights reserved.
//

#import "ZSLiveCollectionViewCell.h"
#import <IJKMediaFramework/IJKMediaFramework.h>

@interface ZSLiveCollectionViewCell()
@property (weak, nonatomic) IBOutlet UILabel *lblName;

@property (nonatomic,strong)IJKFFMoviePlayerController * moviePlayer;

//占位图片
@property (nonatomic,weak)UIImageView * placeHolderView;


@end

@implementation ZSLiveCollectionViewCell


-(UIImageView *)placeHolderView{

    if (!_placeHolderView) {
        UIImageView * imgView = [[UIImageView alloc]init];
        imgView.frame = self.contentView.bounds;
        imgView.image = [UIImage imageNamed:@"profile_user_414x414"];
        [self.contentView addSubview:imgView];
        _placeHolderView = imgView;
    }
    return _placeHolderView;
}




-(void)setLive:(ZSLive *)live{
    
    _live = live;
    
    _lblName.text = live.myname;
    
    [self setupPlayer];

    
}


//设置player
-(void)setupPlayer{

//http://hdl.9158.com/live/13534b277fbccecca175a8374e9fb7ce.flv

//http://hdl.9158.com/live/1208a0496d53d5d8ccc2ffcef28bcf0d.flv

    IJKFFOptions *options = [IJKFFOptions optionsByDefault];
//    [options setPlayerOptionIntValue:1  forKey:@"videotoolbox"];
    // 帧速率(fps) （可以改，确认非标准桢率会导致音画不同步，所以只能设定为15或者29.97）
    [options setPlayerOptionIntValue:29.97 forKey:@"r"];
    // -vol——设置音量大小，256为标准音量。（要设置成两倍音量时则输入512，依此类推
    [options setPlayerOptionIntValue:512 forKey:@"vol"];

    self.moviePlayer = [[IJKFFMoviePlayerController alloc]initWithContentURLString:_live.flv withOptions:options];
    self.moviePlayer.view.frame = self.contentView.bounds;
    [self.contentView addSubview:self.moviePlayer.view];

    
    [self.moviePlayer prepareToPlay];
    
    [self.moviePlayer play];
}





- (void)awakeFromNib {
    [super awakeFromNib];

    
    
}

@end
